import { Controller, Get, Post, Body, Patch, Param, Delete,Headers } from '@nestjs/common';
import { UserBehaviorService } from './user-behavior.service';
import { CreateUserBehaviorDto } from './dto/create-user-behavior.dto';
import { UpdateUserBehaviorDto } from './dto/update-user-behavior.dto';
import { ApiOperation, ApiResponse } from '@nestjs/swagger';
import { QueryDto } from './dto/query.dto';
import { UserInfoDto } from '../model/dto/user-info.dto';

@Controller('user-behavior')
export class UserBehaviorController {
  constructor(private readonly userBehaviorService: UserBehaviorService) {}

  @Post()
  @ApiOperation({
    summary: '创建template',
    description: '创建template',
  })
  @ApiResponse({
    status: 200,
    description: '创建成功'
  })
  create(
    @Body() createUserBehaviorDto: CreateUserBehaviorDto,
    @Headers('user') user:UserInfoDto
  ) {
    return this.userBehaviorService.create(createUserBehaviorDto,user);
  }

  @Get()
  @ApiOperation({
    summary: '获取template列表',
    description: '获取template列表',
  })
  @ApiResponse({
    status: 200,
    description: '获取成功',
    type: [UpdateUserBehaviorDto],
  })
  findAll(query: QueryDto) {
    return this.userBehaviorService.findAll(query);
  }

  @Get(':id')
  findOne(@Param('id') id: string) {
    return this.userBehaviorService.findOne(+id);
  }

  @Patch(':id')
  update(@Param('id') id: string, @Body() updateUserBehaviorDto: UpdateUserBehaviorDto) {
    return this.userBehaviorService.update(+id, updateUserBehaviorDto);
  }

  @Delete(':id')
  remove(@Param('id') id: string) {
    return this.userBehaviorService.remove(+id);
  }
}
